package com.mobiusws.util;


public class ExportingUtil
{
	public  long intXORMask(long msisdn, long bits)
	{
		long result;
		
		result = msisdn^bits;
		
		return result;
	}
	
	public String intXORMask(String strMsisdn, long bits)
	{
		String strRet=strMsisdn;
		
		try
		{
			long msisdn = Long.parseLong(strMsisdn);
			
			long result = intXORMask(msisdn, bits);
			
			strRet = ""+result;
		}
		catch (NumberFormatException e)
		{
			//e.printStackTrace();
		}
		
		return strRet;
	}
	
	public static String[] getStringAndFlagArray(String inputStr, ExportReport reportStruct)
	{
		String [] array = new String[2];
		if (inputStr == null) {
			return array;
		}
		if(reportStruct.getTableName() != null) {
			if ("daily_fraud_detail_report".equals(reportStruct.getTableName().trim())
				|| "daily_fraud_summary_report".equals(reportStruct.getTableName().trim())) {
				array = inputStr.split("_");
			} else if("daily_international_gateway_report".equals(reportStruct.getTableName().trim())) {
				array[0] = inputStr;
				array[1] = "0";
			}
		}	else {
			array[0] = inputStr;
			array[1] = "0";
		}
		return array;
	}
	
	public static String getCorrectString(String inputStr, ExportReport reportStruct)
	{
		if (inputStr == null) {
			return inputStr;
		}
		
		if(reportStruct.getTableName() != null) {
			if ("daily_fraud_detail_report".equals(reportStruct.getTableName().trim())
				|| "daily_fraud_summary_report".equals(reportStruct.getTableName().trim())
				|| "daily_international_gateway_report".equals(reportStruct.getTableName().trim())
				) {
				return inputStr.split("_")[0];
			}
		}
		return inputStr;
	}
	
}
